<?php
    header("Content-type: text/html; charset=utf-8");
    $localhosts='localhost';
    $usernames='root';
    $passwords='root';
    //连接数据库
    $conn=mysqli_connect($localhosts,$usernames,$passwords);
    $query='use flower';
//创建列flowers
    mysqli_query($conn,$query);
    // include_once "con1.php";

    $zheng=$_GET['zheng'];
    if($zheng=='telLogin'){
        $username=$_GET['username'];
        $password=$_GET['password'];
        $query="select tel_active from flowers where tel ='$username'";
        $res= mysqli_query($conn,$query);
        $res=mysqli_fetch_array($res);
        if(!$res){
            die('3');//用户名不存在
        }
        else {
            if($res[0]==$password){
                setcookie('username',$username,time()+3600*24);
                die('1');//登录成功
            }
            else {
                die('2');//验证码错误
            }
        }
    }
    elseif($zheng=='staLogin'){
        $username=$_GET['username'];
        $password=$_GET['password'];
        $query="select password from flowers where tel ='$username'";
        $res= mysqli_query($conn,$query);
        $res=mysqli_fetch_array($res);
        if(!$res){
            die('3');
        }
        else {
            if($res[0]==$password){
                die('1');
            }
            else {
                die('4');//密码错误
            }
        }
    }
    elseif($zheng=='getverif') {
        $username=$_GET['username'];
        // die ($_GET['username']);
        $query="select tel_active from flowers where tel ='$username'";
        $res=mysqli_query($conn,$query);
        $res=mysqli_fetch_array($res);
        if($res){
            die("$res[0]");
        }
        else {
            die('0');//用户名不存在或没有输入用户名
        }
    }
   
?>